package com.qdu.web.controller.bussiness;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.qdu.common.annotation.Log;
import com.qdu.common.core.controller.BaseController;
import com.qdu.common.core.domain.AjaxResult;
import com.qdu.common.enums.BusinessType;
import com.qdu.bussiness.domain.BusInventory;
import com.qdu.bussiness.service.IBusInventoryService;
import com.qdu.common.utils.poi.ExcelUtil;
import com.qdu.common.core.page.TableDataInfo;

/**
 * 库存信息Controller
 * 
 * @author qdu
 * @date 2022-03-06
 */
@RestController
@RequestMapping("/bussiness/inventory")
public class BusInventoryController extends BaseController
{
    @Autowired
    private IBusInventoryService busInventoryService;

    /**
     * 查询库存信息列表
     */
    @PreAuthorize("@ss.hasPermi('bussiness:inventory:list')")
    @GetMapping("/list")
    public TableDataInfo list(BusInventory busInventory)
    {
        startPage();
        List<BusInventory> list = busInventoryService.selectBusInventoryList(busInventory);
        return getDataTable(list);
    }

    /**
     * 导出库存信息列表
     */
    @PreAuthorize("@ss.hasPermi('bussiness:inventory:export')")
    @Log(title = "库存信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, BusInventory busInventory)
    {
        List<BusInventory> list = busInventoryService.selectBusInventoryList(busInventory);
        ExcelUtil<BusInventory> util = new ExcelUtil<BusInventory>(BusInventory.class);
        util.exportExcel(response, list, "库存信息数据");
    }

    /**
     * 获取库存信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('bussiness:inventory:query')")
    @GetMapping(value = "/{inventoryId}")
    public AjaxResult getInfo(@PathVariable("inventoryId") Long inventoryId)
    {
        return AjaxResult.success(busInventoryService.selectBusInventoryByInventoryId(inventoryId));
    }
}
